Ext.define('CDR.view.report.TariffReportGrid', {
	extend: 'Ext.grid.Panel',
	alias: 'widget.tariff-call-report-grid',
	type: '',
	entityTree: null,
	initComponent: function(){
		var me = this;
		if(me.type ==  'entity'){
			me.entityTree = Ext.create('CDR.view.report.TariffReportEntityTree', {
				target: me
			});
			me.store = Ext.create('CDR.store.report.ReportGridStore');
		}
		me.callParent(arguments);
	},
	tbar: ['-',{
		iconCls:'icon-add',
		action: 'add',
		text: 'Add'
	}, '', {
		iconCls:'icon-clear',
		action: 'clear',
		text: 'Clear all'
	}],
	hideHeaders: true,
	columns: [{
        xtype: 'rownumberer',
        width: 30
    },{
    	dataIndex:'type', 
    	width: 30,
    	renderer: function (value, metadata, record, rowIndex, colIndex, store, grid) {
    		if(record.data.type =="contact"){
    			return "<img src='resources/app/images/pbx.png'/>"
    		} else if (record.data.type =="pbx"){
    			return "<img src='resources/app/images/pbx-tree.png'/>"
    		} else {
    			return "<img src='resources/app/images/root_organization.png'/>"
    		}
    	} 
    },{
		dataIndex:'entityPath', 
		flex: 1
	},{
		xtype:'actioncolumn',
        items:[{
            icon: 'resources/app/images/delete.png',
            tooltip: 'Delete',
            handler: function (grid, rowIndex, colIndex, item, e) {
            	grid.store.removeAt(rowIndex);
            }
        }],
        width: 30
	}],
	showView : function(){
		var me = this;
		var box = me.el.getBox();
		if(me.type ==  'entity'){
			me.entityTree.showAt([box.x + 24,box.y + box.height], true);
		}
	}
	 
});